package com.liuboss.controller;


import com.liuboss.common.lang.Result;
import com.liuboss.entity.User;
import com.liuboss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 永乐大帝！！！
 * @since 2021-12-31
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired               
    UserService userService;

    @GetMapping("/index")
    public Object index(){
        return userService.getById(1L);
    }

    @GetMapping("/index01")
    public Result index01(){
        User user = userService.getById(1L);
        return Result.succ(200,"操作成功！",user);
    }
    @GetMapping("/index02")
    public Result index02(){
        User user = userService.getById(1L);
        return Result.succ(user);
    }

    @PostMapping("/save")
    public Result save(@Validated @RequestBody User user){
        return Result.succ(user);
    }
}
